package com.shihang.core.apollo.constant;

public enum Level {


    DEBUG("DEBUG", 4),
    INFO("INFO", 3),
    WARN("WARN", 2),
    ERROR("ERROR", 1),
    ;

    private String name;
    private int weight;

    Level(String name, int weight) {
        this.name = name;
        this.weight = weight;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }


    public static String getLevel(String name) {
        for (Level level : Level.values()) {
            if (level.getName().equalsIgnoreCase(name)) {
                return level.getName();
            }
        }
        return "";

    }


    public static int getWeight(String name) {
        for (Level level : Level.values()) {
            if (level.getName().equalsIgnoreCase(name)) {
                return level.weight;
            }
        }
        return 0;

    }


}
